<div class="layuimini-main">

    <div class="layui-form layuimini-form">

        <div class="layui-form-item">
            <label class="layui-form-label">生成数量</label>
            <div class="layui-input-block">
                <select name="numbers" lay-filter="aihao">
                    <option value="50">50</option>
                    <option value="100" selected="">100</option>
                    <option value="200">200</option>
                    <option value="500">500</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">下载次数</label>
            <div class="layui-input-block">
                <input type="radio" name="frequency" value="5" title="5次" checked="">
                <input type="radio" name="frequency" value="10" title="10次">
                <input type="radio" name="frequency" value="10" title="50次">
                <input type="radio" name="frequency" value="999999999" title="不限制">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.post(
                "/admin/camille/api/addapi",
                data.field,
                function (res) {
                    if (res.status) {
                        layer.msg(res.message, { time: 2000 });
                    } else {
                        layer.msg(res.message, { time: 2000 });
                    }
                }, 'json');

                // 关闭弹出层
                layer.close(parentIndex);
            
            return false;
        });

    });
</script>